﻿/* PROJECT ETERNAL - SOURCE CODE
 * RELEASED UNDER GNU GPL v3
 * 
 * A STUDENT WRITTEN OPEN SOURCE SIDE SCROLLING VIDEO GAME
 * 
 */

//CHANGE LOG
/* 2.20.12 - ADDED CLASS - RUNS - BACON
 * 
 */

/*
 * 
 * 
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace ETERNAL
{
    class Player : Entity
    {
        KeyboardState kState;
        SpriteFont DEVtool;

        public Player() : base() {
            objectPos = new Vector2(100, 100);
            animatedSprite = new AnimatedSprite();
            maxHealth = 10;
            health = maxHealth - 5;
        }
        public override void LoadContent(ContentManager cM)
        {
            animatedSprite.Load(cM, "bitmap Robot");
            DEVtool = cM.Load<SpriteFont>("DEVTOOLS");
        }
        public override void UpdateObject()
        { 
            //potentially redone later?
            kState = Keyboard.GetState();
            if (kState.IsKeyDown(Keys.A))
            {
                objectPos.X -= 10;
                animatedSprite.RunAnimation();
            }
            if (kState.IsKeyDown(Keys.D))
            {
                objectPos.X += 10;
                animatedSprite.RunAnimation();
            }
            if (kState.IsKeyDown(Keys.W))
            {
                objectPos.Y -= 10;
                animatedSprite.RunAnimation();
            }
            if (kState.IsKeyDown(Keys.S))
            {
                objectPos.Y += 10;
                animatedSprite.RunAnimation();
            }
            if (kState.IsKeyDown(Keys.Up))
                animatedSprite.RotateSprite(true);
            if (kState.IsKeyDown(Keys.Down))
                animatedSprite.RotateSprite(false);

            //really basic stuff, will be updated later
            if (objectPos.X < 0)
                objectPos.X = 0;
            if (objectPos.Y < 0)
                objectPos.Y = 0;
            if (objectPos.Y > 500)
                objectPos.Y = 500;
            if (objectPos.X > 500)
                objectPos.X = 500;
        }

        public override void DrawObject(SpriteBatch spriteBatch)
        {
            animatedSprite.DrawSprite(spriteBatch, objectPos);
            spriteBatch.DrawString(DEVtool, "PLAYER POS: " + objectPos, new Vector2(0, 0), Color.White);
            spriteBatch.DrawString(DEVtool, "PLAYER HEALTH: " + health, new Vector2(0, 10), Color.White);
            spriteBatch.DrawString(DEVtool, "PLAYER ORIGIN: " + animatedSprite.origin, new Vector2(0, 20), Color.White);
        }
    }
}
